package day19.homework;

import java.io.*;

public class Copy {
    public void testInputStream(String a,String b) {
        int input = 0;
        FileInputStream fisa = null;
        FileOutputStream fisb = null;
        try {
            fisa = new FileInputStream(a);
            fisb = new FileOutputStream(b);
            input = fisa.available();
            byte [] bytes = new byte[input];
            fisa.read(bytes);
            fisb.write(bytes);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fisa != null && fisb != null){
                try {
                    fisa.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        Copy copy = new Copy();
        copy.testInputStream("1.txt","2.txt");
    }
}
